Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove locale dependent FileSystemException check #21633

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

niklasf
Copy link

@niklasf niklasf commented Sep 23, 2024

In SourceFile, files that do not exist are expected and related exceptions should be ignored. There are two relevant cases:

scala> java.nio.file.Files.newInputStream(java.nio.file.FileSystems.getDefault().getPath("does-not-exist"))
java.nio.file.NoSuchFileException: does-not-exist

scala> java.nio.file.Files.newInputStream(java.nio.file.FileSystems.getDefault().getPath("regular-file-instead-of-directory/filename"))
java.nio.file.FileSystemException: regular-file-instead-of-directory/filename: Not a directory

Ideally, other I/O errors would be propagated to the caller.

However, there is no reliable way to distinguish them based on the exceptions alone. In particular, the message cannot be checked, because it depends on the operating system and it is localized.

Revert the addition of the check and just accept this.


Resolves the following concrete bug:

  1. Use an operating system that localizes strerror, like Debian.
  2. Check out https://github.com/lichess-org/lila before lichess-org/lila@8610e6f
  3. LANGUAGE=fr sbt compile
  4. ICE with java.nio.file.FileSystemException: lila/src/main/scala/future.scala: N'est pas un dossier (stacktrace)

Not sure how to exercise locale dependent issues in a unit test.


cc @som-snytt in case I misinterpreted 159da44 and distinguishing other I/O errors is not optional.

Fin SourceFile, files that do not exist are expected and related exceptions
should be ignored. There are two relevant cases:

    scala> java.nio.file.Files.newInputStream(java.nio.file.FileSystems.getDefault().getPath("does-not-exist"))
    java.nio.file.NoSuchFileException: does-not-exist

    scala> java.nio.file.Files.newInputStream(java.nio.file.FileSystems.getDefault().getPath("regular-file-instead-of-directory/filename"))
    java.nio.file.FileSystemException: regular-file-instead-of-directory/filename: Not a directory

Ideally, other I/O errors would be propagated to the caller.

However, there is no reliable way to distinguish them based on the
exceptions alone. In particular, the message cannot be checked, because
it depends on the operating system and it is localized.

Revert the addition of the check and just accept this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant